//
//  RVInfoManageController.swift
//  AirTravel
//
//  Created by apple on 2021/11/15.
//

import UIKit
import DNSPageView
class RVInfoManageController: CommonVC {

    @IBOutlet weak var contentView: PageContentView!
    
    @IBOutlet weak var titleView: PageTitleView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        head.title.text = "常用信息"
        confPageView()
    }

    func confPageView() {
        let style = PageStyle()
        style.titleViewBackgroundColor = UIColor.white
        style.isShowCoverView = false
        style.titleSelectedColor = UIColor(hexString: "#FF8A00")
        style.isShowBottomLine = true
        style.titleViewBackgroundColor = UIColor.clear
        style.isTitleScaleEnabled = true
        style.bottomLineColor = UIColor(hexString: "#FF8A00")
        style.isTitleViewScrollEnabled = false
        style.bottomLineWidth = "已完成".getWitdhBy(font: UIFont.systemFont(ofSize: 15))+10;
        
        // 设置标题内容
        //let titles = ["出行人", "联系人"]
        let titles = ["联系人"]

        // 创建每一页对应的 controller
        let _: [UIViewController] = titles.map { title -> UIViewController in
            
            if title == "出行人"{
                let controller = RVCommonListController(type:.passenger)
                addChild(controller)
                return controller
            }else{
                let controller = RVCommonListController(type:.contacter)
                addChild(controller)
                return controller
            }
            
        }

        // 创建 PageViewManager 来设置它们的样式和布局
        let pageViewManager = PageViewManager(style: style,
                                          titles: titles,
                                          childViewControllers: children,
                                          currentIndex: 0,
                                          titleView: titleView,
                                          contentView: contentView)
        
        
    }    

}


extension String{
    
    func getWitdhBy(font: UIFont) -> CGFloat{
        
        
        return (self as NSString).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: 0),
                                                     options: .usesLineFragmentOrigin,
                                                     attributes: [NSAttributedString.Key.font : font],
                                                     context: nil).width
        
    }
    
}
